package com.zqx.combination.containercomponent;

import com.zqx.combination.abcomponent.AbstractFile;
import lombok.extern.slf4j.Slf4j;

import java.util.ArrayList;

/**
 * 容器构件类
 * @author zqx
 * @date 2018/09/03
 */
@Slf4j
public class Folder extends AbstractFile {

    private ArrayList<AbstractFile> fileList = new ArrayList<AbstractFile>();
    private String name;

    public Folder(String name) {
        this.name = name;
    }

    @Override
    public void add(AbstractFile file) {
        fileList.add(file);
    }

    @Override
    public void remove(AbstractFile file) {
        fileList.remove(file);
    }

    @Override
    public AbstractFile getChile(int i) {
        AbstractFile abstractFile = fileList.get(i);
        return abstractFile;
    }

    @Override
    public void killVirus() {
        log.info("对文件夹"+name+"进行杀毒");
        for (Object obj:fileList) {
            ((AbstractFile)obj).killVirus();
        }

    }
}
